#include "scaler.h"

void scaler::setIndex(string index_value)
{
    this->index = index_value;
}

void scaler::setItems(map<string, string> items_value)
{
    this->items = items_value;
}

void scaler::addItem(string key, string value)
{
    this->items[key] = value;
}


string scaler::getIndex()
{
    return this->index;
}

map<string, string> scaler::getItems()
{
    return this->items;
}

string scaler::getItemsStr()
{
    string itemStr = "";
    map<string, string>::iterator iter;
    for (iter = this->items.begin(); iter != this->items.end(); iter++)
    {
        itemStr = itemStr + iter->first + "=\"" + iter->second + "\",";
    }

    itemStr = itemStr.substr(0, itemStr.length() - 1);
    string result = "{" + itemStr + "}";

    return result;
}

string scaler::toString()
{
    string itemStr = "";
    map<string, string>::iterator iter;
    for (iter = items.begin(); iter != items.end(); iter++)
    {
        itemStr = itemStr + iter->first + "=\"" + iter->second + "\",";
    }

    itemStr = itemStr.substr(0, itemStr.length() - 1);
    string result = index + "{" + itemStr + "}";

    return result;
}